﻿using SheepCultivation.Common.EFDb;
using SheepCultivation.Common.Infrastructure.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SheepCultivation.Common.Infrastructure.Repository
{
    public class BaseRepsoitory<T> : IBaseRepository<T> where T : class, new()
    {
        public readonly EFDBContext db;

        public BaseRepsoitory(EFDBContext db)
        {
            this.db = db;
        }

        public int Add(T entity)
        {
            db.Set<T>().Add(entity);
            return db.SaveChanges();
        }

        public IQueryable<T> GetAll()
        {
            return db.Set<T>().AsQueryable();
        }
    }
}
